﻿using LJ.EventBus.FastDog.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJ.EventBus.FastDog.Transport.Abstractions;

/// <inheritdoc />
/// <summary>
/// 消息队列消费者客户端
/// </summary>
public interface IConsumerClient : IDisposable
{

    /// <summary>
    /// 创建（如果需要）并获取主题标识符
    /// </summary>
    /// <param name="topicNames">Names of the requested topics</param>
    /// <returns>Topic identifiers</returns>
    ICollection<string> FetchTopics(IEnumerable<string> topicNames);

    /// <summary>
    /// 请求的主题名称
    /// </summary>
    /// <param name="topics"></param>
    void Subscribe(IEnumerable<string> topics);

    /// <summary>
    /// 开始监听
    /// </summary>
    void Listening(TimeSpan timeout, CancellationToken cancellationToken);

    /// <summary>
    /// 消息消费完成时手动提交消息偏移量
    /// </summary>
    void Commit(object? sender);

    /// <summary>
    /// 拒绝消息并恢复
    /// </summary>
    void Reject(object? sender);

    public Func<TransportMessage, object, Task>? OnMessageCallback { get; set; }
    public Action<LogMessageEventArgs>? OnLogCallback { get; set; }

}